{% macro select(params) %}
    <div class="form-group">
        {% if params.labelName %}
            {% import _self as form %}
            {{ form.label(params.labelName, params.id) }}
        {% endif %}
        <div class="col-md-2">
            <select id="{{ params.id }}" name="{{ params.name }}"  class="{{ params.class|default(null) }} form-control">
                {% if params.setDefault is not defined or params.setDefault == true %}<option value="0">-- Изберете --</option>{% endif %}
                {% for Object in params.objects %}
                    <option {% if params.CurrentObject is defined and params.CurrentObject and Object.id == params.CurrentObject.id %}selected="selected" {% endif %}value="{{Object.id}}">{{ Object.name }}</option>
                {% endfor %}
            </select>
        </div>
    </div>
{% endmacro %}

{% macro textarea(params) %}
    <div class="form-group">
        {% if params.labelName is defined %}
            {% import _self as form %}
            {{ form.label(params.labelName, params.id|default(null)) }}
        {% endif %}
        <div class="col-md-2{% if params.inputGroupName is defined %} input-group {% endif %}">
            <textarea class="{{ params.class|default(null) }}"  rows="{{ params.rows|default(5) }}" cols="{{ params.cols|default(120) }}" name='{{ params.name|default(null) }}' id="{{ params.id|default(null) }}" >{{ params.value|default(null) }}</textarea>
            {% if params.inputGroupName is defined %}
                <span class="input-group-addon">{{ params.inputGroupName }}</span>
            {% endif %}
        </div>
    </div>
{% endmacro %}

{% macro input(params) %}
    <div class="form-group">
        {% if params.labelName is defined %}
            {% import _self as form %}
            {{ form.label(params.labelName, params.id|default(null)) }}
        {% endif %}
        <div class="{{ params.groupClass|default('col-md-2') }}{% if params.inputGroupName is defined %} input-group {% endif %}">
            <input {{ params.attr|default('') }} type="{{ params.type|default('text') }}" placeholder="{{ params.placeholder|default(null) }}" class="{{ params.class|default(null) }} {% if params.clearClass is not defined %}form-control input-md{% endif %}" name='{{ params.name|default(null) }}' id="{{ params.id|default(null) }}" value="{{ params.value|default(null) }}">
            {% if params.inputGroupName is defined %}
                <span class="input-group-addon">{{ params.inputGroupName }}</span>
            {% endif %}
        </div>
    </div>
{% endmacro %}

{% macro checkbox(params) %}
    <div class="form-group">
        {% if params.labelName is defined %}
            {% import _self as form %}
            {{ form.label(params.labelName, params.id|default(null)) }}
        {% endif %}
        {% if params.value|default(null) %}
                {% set checked = 'checked="checked"' %}
            {% else %}
                {% set checked = '' %}
        {% endif %}
        <div class="col-md-2{% if params.inputGroupName is defined %} input-group {% endif %}">
            <input type="{{ params.type|default('checkbox') }}" class="{{ params.class|default(null) }}" name='{{ params.name|default(null) }}' id="{{ params.id|default(null) }}" {{ checked }} value="{{ params.value|default(1) }}">
            {% if params.inputGroupName is defined %}
                <span class="input-group-addon">{{ params.inputGroupName }}</span>
            {% endif %}
        </div>
    </div>
{% endmacro %}

{% macro file(params) %}
    <div class="form-group">
        {% if params.labelName is defined %}
            {% import _self as form %}
            {{ form.label(params.labelName, params.id|default(null)) }}
        {% endif %}
        <div class="col-md-2{% if params.inputGroupName is defined %} input-group {% endif %}">
            <input type="{{ params.type|default('file') }}" class="{{ params.class|default(null) }}" name='{{ params.name|default(null) }}' id="{{ params.id|default(null) }}" multiple>
            {% if params.inputGroupName is defined %}
                <span class="input-group-addon">{{ params.inputGroupName }}</span>
            {% endif %}
        </div>
    </div>
{% endmacro %}
    
{% macro label(name, id) %}
    <label for="{{ id }}" class="col-sm-2 control-label">{{ name }}</label>
{% endmacro %}

{% macro submit(conf) %}
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-3">
            <a href="{{ path(conf.backword|default("admin_products")) }}" class="btn btn btn-default"><i class="glyphicon glyphicon-chevron-left"></i> Назад</a>
            <button type="submit" class="btn btn-primary"><i class="glyphicon glyphicon-floppy-save"></i> {{ conf.name|default('Запази') }}</button>
        </div>
    </div>
{% endmacro %}